//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

char a[13]="000000000000";
int n, sum, x, i, j, k;
int main (){
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	scanf("%d", &n);
	for(x=1, j=2, sum=0;x<=n;++j){
		++sum;
			//j-toBin-a
			k=12;
			for(i=1;i<2049;i=i<<1){
				a[k--]=(j&i)?'1':'0';
			}
		x=atoi(a);
	}
	printf("%d", sum);
	return 0;
}

